<?php
require_once("vcl/vcl.inc.php");
require_once("lib/db_connection.php");
//Includes
use_unit("components4phpfull/jtsitetheme.inc.php");
use_unit("forms.inc.php");
use_unit("extctrls.inc.php");
use_unit("stdctrls.inc.php");

//Class definition
class CompanyLegal extends Page
{
       public $Image3 = null;
       public $btnCancel = null;
       public $btnSubmit = null;
       public $JTSiteTheme1 = null;
       public $memoInvoiceLegal = null;
       public $lblInvoiceLegal = null;
       function btnCancelClick($sender, $params)
       {
       redirect('vehicle_list.php?company_id='.$_SESSION['company_id']);
       }

       function btnSubmitClick($sender, $params)
       {

       $result=mysql_query("select * from company_legal_tbl where company_id='".$_SESSION['company_id']."'");
       $count=mysql_num_rows($result);
       if($count==0)
       {
       mysql_query("insert into company_legal_tbl (company_id,
       invoice_legal)

       Values('".$_SESSION['company_id']."',
       '".$this->memoInvoiceLegal->Text."')") or die ("insert legal - " . mysql_error());
       }
       else
       {
       mysql_query("update company_legal_tbl set
       invoice_legal='".$this->memoInvoiceLegal->Text."'
       where company_id='".$_SESSION['company_id']."'") or die ("update legal - " . mysql_error());
       }
       redirect('vehicle_list.php?company_id='.$_SESSION['company_id']);
       }

       function CompanyLegalCreate($sender, $params)
       {

       $query = "select * from company_legal_tbl where company_id='".$_SESSION['company_id']."'";
       $result_show = mysql_query($query)or die("SELECT LEGAL - " . mysql_error());
       $row= mysql_fetch_array($result_show);

       $this->memoInvoiceLegal->Text = $row['invoice_legal'];
       }

}

global $application;

global $CompanyLegal;

//Creates the form
$CompanyLegal=new CompanyLegal($application);

//Read from resource file
$CompanyLegal->loadResource(__FILE__);

//Shows the form
$CompanyLegal->show();

?>